package com.leyou.common.exception.pojo;

import lombok.Getter;

import java.util.Objects;

/**
 * 自定义异常类(封装自己定义的异常格式)
 */
@Getter
public class LyException extends RuntimeException{

    private Integer status;

    /**
     * 提供构造方法
     */
    public LyException(Integer status,String message){
        super(message);
        this.status = status;
    }
    /**
     * 使用枚举构造对象
     */
    public LyException(ExceptionEnum exceptionEnum){
        super(exceptionEnum.getMessage());
        this.status = exceptionEnum.getStatus();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LyException that = (LyException) o;
        return Objects.equals(status, that.status);
    }

    @Override
    public int hashCode() {
        return Objects.hash(status);
    }
}
